
import { getFileList } from '@/services';
import { FileList } from '@/utils/poster';
import { Effect, Reducer } from 'umi';
export interface IndexModelState {
    name: string;
    FileList: Array<FileList>,
    lens: number
}
export interface IndexModelType {
    namespace: 'file';
    state: IndexModelState;
    effects: {
        getFileList: Effect;
    };
    reducers: {
        save: Reducer<IndexModelState>;
    };
}
const IndexModel: IndexModelType = {
    namespace: 'file',
    state: {
        name: '',
        FileList: [],
        lens: 0
    },

    effects: {
        *getFileList({ payload }, { call, put }) {
            let result = yield call(getFileList, payload.params);
            yield put({
                type: 'save',
                payload: {
                    FileList: result.data[0],
                    lens: result.data[1]
                }
            })
        },
    },
    reducers: {
        save(state, action) {
            return {
                ...state,
                ...action.payload,
            };
        },
    },

};

export default IndexModel;